package com.lovo.shirodemo.controller;

import com.lovo.shirodemo.result.GlobalHandleException;
import com.lovo.shirodemo.result.ResponseResult;
import com.lovo.shirodemo.result.ResultCode;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/students")
@ResponseResult
public class StudentController {
    @GetMapping
    public Object show() throws GlobalHandleException {
//        Subject subject = SecurityUtils.getSubject();
//        if(subject.hasRole("系统管理员")){
//            return "show";
//        }else{
//            throw new GlobalHandleException(ResultCode.USER_AUTHORIZATION_ERROR);
//        }
        return "show";

    }
//    @RequiresRoles("系统管理员")
    @PostMapping
    public Object add(){
        return "add";
    }
//    @RequiresPermissions("修改学生")
    @PutMapping
    public Object update(){
        return "update";
    }
//    @RequiresPermissions("删除学生")
    @DeleteMapping
    public Object delete(){
        return "delete";
    }
}
